package logic

import (
	"context"
	"hm-zero-mall/apps/user/models"
	"time"

	"hm-zero-mall/apps/user/rpc/internal/svc"
	"hm-zero-mall/apps/user/rpc/pb"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteUserInfoLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteUserInfoLogic {
	return &DeleteUserInfoLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeleteUserInfo 删除用户信息
func (l *DeleteUserInfoLogic) DeleteUserInfo(in *pb.UserIdRequest) (*pb.Empty, error) {
	err := l.svcCtx.UserModel.Update(l.ctx, &models.User{Id: in.UserId, Status: 2, DeleteTime: time.Now().Unix()})
	return &pb.Empty{}, err
}
